<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

    </style>
</head>

<body>
    <div id="app">
        <input type="button" value="走起" @click="go">
        <div style="width:200px;height:40px;border:1px solid black">
            <div :style="{width:w+'px'}" style="height: 100%;background-color: red;"></div>
        </div>
        <p>{{parseInt(w/200*100)}}%</p>
    </div>
</body>

</html>
<script src="./js/vue2.js"></script>
<script>

    let vm = new Vue({
        el: "#app",
        data: {
            w:0
        },
        methods: {
            go(){
                let myTimer = setInterval(()=>{
                    // 1、数据处理
                    this.w+=2;
                    if(this.w>=200){
                        this.w=200;
                        clearInterval(myTimer);
                    }
                },20)
            }
        }
    });

</script>